package gui;

import core.para.Para;
import gui.cen.disp.Message;
import gui.cen.disp.PrototypeDisplay;
import gui.cen.disp.SeqDisplay;
import gui.utils.Borders;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Font;
import javax.swing.*;
import javax.swing.border.TitledBorder;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class VTL1 extends JPanel{
    
    public static int FLOWCHART = 0;
    public static int TRANSCRIPTS = 1;
    public static int LOG = 2;
    
    private PrototypeDisplay hs;
    public VTL0 vtl0;
    private JPanel holder;
    private CardLayout layout;
    private North north;
    private Message msg;
    
    public VTL1(VTL0 vtl0){
        this.setLayout(new BorderLayout());
        this.vtl0 = vtl0;
        this.setBorder(BorderFactory.createEmptyBorder(2,4,4,4));
        
        north = new North(this);
        this.add(north, BorderLayout.NORTH);
        
        holder = new JPanel();
        layout = new CardLayout();
        holder.setLayout(layout);
        hs = new PrototypeDisplay();
        hs.renderFrontEnd(0);
        holder.add(hs, "FLOWCHART");
        layout.show(holder, "FLOWCHART");
        
        this.add(holder, BorderLayout.CENTER);
        
        //add the msg bar here
        JPanel p0 = new JPanel(new BorderLayout());
        p0.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Message", TitledBorder.LEFT, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 10)));
        msg = new Message();
        msg.tickMSG("Welcome to VTBuilder. Use the Start menu to begin.");
        p0.add(msg,BorderLayout.CENTER);
        this.add(p0, BorderLayout.SOUTH);
        
        
        Borders.setCharHeightAndWidth();
        this.setVisible(true);
    }

    public int getWidthOfApp(){return vtl0.getWidth();}
    public void tickMSG(String m){msg.tickMSG(m);}
    public void renderFrontEnd(int n){hs.renderFrontEnd(n);}
    public void idPrgA(int which){north.idPrgA(which);}
    public void dPrgA(int which, int val){north.dPrgA(which, val);}
    public void loadCard(int which){
        if(which==FLOWCHART){
            layout.show(holder, "FLOWCHART");
        }
        else if(which==TRANSCRIPTS){
            SeqDisplay sd = new SeqDisplay(this);
            holder.add(sd, "TRANSCRIPTS");
            layout.show(holder, "TRANSCRIPTS");
            tickMSG("Saved to: " + Para.PATH_TO_OUTPUT);
        }
    }
}